package top.eggcode.common.model;

import lombok.Data;
import org.apache.shiro.authc.AuthenticationToken;
import top.eggcode.common.auth.SessionTokenUtil;

/**
 * Title:
 * Description: TODO
 * Date: 2021/4/15 10:41
 *
 * @author JiaQi Ding
 * @version 1.0
 */
@Data
public class SessionToken implements AuthenticationToken {

    private static final long serialVersionUID = 1L;

    private String token;

    public SessionToken(String token) {
        this.token = token;
    }

    /**
     * 获取委托人
     *
     * @return username
     */
    @Override
    public Object getPrincipal() {
        return SessionTokenUtil.getUsername(token);
    }

    /**
     * 获取凭证
     *
     * @return token
     */
    @Override
    public Object getCredentials() {
        return token;
    }
}
